﻿using B.S.BasicData.ErrorCode;
using B.S.BasicData.Read.Apilication.Common.MenuRole;
using B.S.BasicData.Read.DTOS;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Read.Controllers
{
    /// <summary>
    /// Api 控制器-角色菜单
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class MenuRoleController : ControllerBase
    {
        private readonly IMediator mediator;

        public MenuRoleController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 角色信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<RoleDTO>>> MenuShow([FromQuery] GetRoleCommand command)
        {
            return mediator.Send(command);
        }

        /// <summary>
        /// 菜单列表树形展示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<MenuRoleDto>>> MenuRoleShow([FromQuery] GetMenuCommand command)
        {
            return mediator.Send(command);
        }

        /// <summary>
        /// 角色菜单信息详情
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<int>>> Showall([FromQuery] GetOneRoleCommand command)
        {
            return mediator.Send(command);
        }

        /// <summary>
        /// 根据登录人显示不同功能
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<RolePremissDTO>>> GetRolePremissHandle([FromQuery] GetRoleMenuCommand request)
        {
            return mediator.Send(request);
        }

    }
}
